<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>vip</title>
    <link rel="stylesheet" href="media/layui/css/layui.css">
</head>
<body>
<form>
    <table>
        <tr>
            <td><label style="color:red"> 学员姓名： </label></td>
            <td><span id="uname"></span></td>
        </tr>

        <tr>
            <td><label style="color:red"> 申请理由： </label></td>
        </tr>

        <tr>
            <td></td>
            <td><textarea placeholder="请输入申请理由" style="width:592px;height:150px;" id="content" name="content"></textarea></td>
        </tr>
    </table>

    <button type="submit" class="layui-btn">申请</button>
</form>

<script src="media/layui/layui.js"></script>
<script src="media/js/jquery.min.js"></script>
<script>

    $("form").submit(function () {
        $.ajax({
            type:"get",
            url:"http://localhost:8080/vip/add.do",
            data:$("form").serialize(),
            success:function (data) {
                alert(data.msg)
                window.location.reload()
            }
        })
        return false
    })

    $(function () {
        $.ajax({
            type: "get",
            url: "http://localhost:8080/OaNew/user/query.do",
            dataType: "json",
            success: function(data) {
                console.log(data)
                if (data.code == 1) {
                    $("#uname").html(data.info)
                } else {
                    layer.msg("获取数据异常")
                }
            }
        })
    })
</script>

<!--表格的展示-->
<div id="table">
    <table class="layui-hide" id="test" lay-filter="test"></table>
</div>

<script>
    layui.use(['table', 'laydate', "laypage", "layer", 'carousel', 'upload', 'element'], function(){
        //初始化table组件对象
        var table = layui.table
            ,laypage =layui.laypage//分页的组件
            ,layer = layui.layer//弹框
            ,laydate = layui.laydate//日期组件
            ,element = layui.element;//元素的操作

        //渲染table
        table.render({
            //z找到table  id叫test的组件
            elem: '#test'
            ,id:"table"
            ,url:"vip/queryVip.do"
            ,totalRow: true
            //这个很关键，就是解析 json数据库中数据的 一定要注意键值
            ,cols: [[
                {field:'id', title:'编号', unresize: true, sort: true, fixed:"left"}
                ,{field:'content', title:'申请理由'}
                ,{field:'uno', title:'学号'}
            ]]
            ,page: true //分页开启


        });

    });
</script>

</body>
</html>
